package com.adou.d8.d6;

import java.util.ArrayList;

public class StudentOperatorImpl2 implements StudentOperator{
    @Override
    public void printInfo(ArrayList<Student> students) {
        System.out.println("//////-全班全部学生信息////////");
        int count1 = 0;
        int count2 = 0;
        for (int i = 0; i < students.size(); i++) {
            System.out.println(students.get(i));
            if('男' == students.get(i).getSex()) {
                count1++;
            } else {
                count2++;
            }
        }
        System.out.println("男生人数:" + count1);
        System.out.println("女生人数:" + count2);
        System.out.println("学生总人数:" + (count1+count2));

    }

    @Override
    public void printScore(ArrayList<Student> students) {
        double avg = 0.0;
        double maxAvg = students.get(0).getScore();
        double minAvg = students.get(0).getScore();
        for (int i = 0; i < students.size(); i++) {
            avg += students.get(i).getScore();

            if(students.get(i).getScore() > maxAvg) maxAvg = students.get(i).getScore();
            if(students.get(i).getScore() < minAvg) minAvg = students.get(i).getScore();

        }
        System.out.println("学生最高分：" + maxAvg);
        System.out.println("学生最低分：" + minAvg);

        System.out.println("平均分：" +((avg-minAvg-maxAvg)/students.size()) );
    }
}
